package com.coursehub.course.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;

/**
 * 课程学生关联实体
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "course_student")
public class CourseStudent {
    
    @EmbeddedId
    private CourseStudentId id;
    
    @MapsId("courseId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "course_id", nullable = false)
    private Course course;
    
    // 在微服务架构中，我们不维护User实体的引用
    // 只存储userId，通过服务调用获取用户信息
    // userId通过CourseStudentId的userId字段映射到数据库的user_id列
    
    public CourseStudent(CourseStudentId id, Course course) {
        this.id = id;
        this.course = course;
    }
}